package com.onlineMIS.ORM.DAO.headQ.supplier.purchase;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;
import org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor;

import com.onlineMIS.ORM.DAO.BaseDAO;
import com.onlineMIS.ORM.entity.headQ.barcodeGentor.ProductBarcode;
import com.onlineMIS.ORM.entity.headQ.supplier.purchase.PurchaseOrder;
import com.onlineMIS.ORM.entity.headQ.supplier.purchase.PurchaseOrderProduct;

@Repository
public class PurchaseOrderProductDaoImpl extends BaseDAO<PurchaseOrderProduct> {

	public int removeItems(int orderId){
		String hql ="DELETE FROM PurchaseOrderProduct WHERE order.id = ?";
		
		Object[] value = {orderId};
		
		int rows = this.executeHQLUpdateDelete(hql, value, true);
		
		return rows;
	}

	public List<PurchaseOrderProduct> selectPurchaseOrderProducts(int id, boolean b) {
		
		DetachedCriteria productBarcodeCriteria = DetachedCriteria.forClass(PurchaseOrderProduct.class);
		
		productBarcodeCriteria.add(Restrictions.eq("order.id", id));
		
		return this.getByCritera(productBarcodeCriteria, true);
	}


}
